package com.efrei.schoolmanager.model.obj;

import java.io.Serializable;

import com.efrei.schoolmanager.exceptions.LogicException;
import com.efrei.schoolmanager.tools.Verifs;


public class Etablissement implements Serializable {
	private static final long serialVersionUID = -6421533698025981030L;
	
	/** Attributes */
	private int etablissementId;
	private String nom;
	private String rue;
	private Ville ville;
	private String telephoneFixe;

	public Etablissement() {
	}

	public Etablissement(String nom, String rue,
			Ville ville, String telephoneFixe) {
		super();
		this.nom = nom;
		this.rue = rue;
		this.ville = ville;
		this.telephoneFixe = telephoneFixe;
	}
	
	@Override
	public String toString() {
		String sep = " - ";
		return new StringBuilder()
			.append(nom)
			.append(sep).append(ville)
			.toString();
	}

	public int getEtablissementId() {
		return etablissementId;
	}

	public void setEtablissementId(int etablissementId) {
		this.etablissementId = etablissementId;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getRue() {
		return rue;
	}

	public void setRue(String rue) {
		this.rue = rue;
	}

	public Ville getVille() {
		return ville;
	}

	public void setVille(Ville ville) {
		this.ville = ville;
	}

	public String getTelephoneFixe() {
		return telephoneFixe;
	}

	public void setTelephoneFixe(String telephoneFixe) {
		this.telephoneFixe = telephoneFixe;
	}
	
	public static void check(String nom, String rue,
			String telephoneFixe) throws LogicException {
		Verifs.checkString(nom.trim(), "nom etablissement invalide");
		Verifs.checkString(rue.trim(), "rue etablissement invalide");
		Verifs.checkNullString(telephoneFixe.trim(), "telephone fix etablissement invalide");
	}
}

